package com.imooc.controller;


import com.imooc.pojo.Bgm;
import com.imooc.pojo.Videos;
import com.imooc.pojo.vo.UsersLikeVideosVo;
import com.imooc.pojo.vo.VideosVo;
import com.imooc.service.BgmService;
import com.imooc.service.UserLikeVideoService;
import com.imooc.service.VideoService;
import com.imooc.utils.FileUtils;
import com.imooc.utils.IMoocJSONResult;
import com.imooc.utils.PageResult;
import com.imooc.utils.ffmpeg.FFMpegDelAudioUtils;
import com.imooc.utils.ffmpeg.FFMpegVideoImageUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.UUID;

@RestController
@Api(value = "用户点赞视频", tags = {"用户对于视频的点赞和取消点赞的操作"})
@RequestMapping("/videos")
public class UserLikeVideoController extends BaseController {
    @Autowired
    private UserLikeVideoService userLikeVideoService;

    @PostMapping("/like")
    @ApiOperation(value = "用户点赞视频或者取消点赞", notes = "用户点赞视频或者取消点赞的接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "用户id", required = true, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "videoId", value = "视频的id", required = true, dataType = "String", paramType = "query"),
    })
    public IMoocJSONResult like(String userId, String videoId) {
        //2006089FFXZBZSRP  2006089GSGD9CKKP
        // 2006099ZG01PXGR4   2006096FM10T5400
        if (StringUtils.isBlank(userId)) {
            return IMoocJSONResult.errorMsg("用户id不能为空");
        }
        if (StringUtils.isBlank(videoId)) {
            return IMoocJSONResult.errorMsg("video id不能为空");
        }

       /* PageResult<VideosVo> result = videoService.list(
                video,
                isSaveRecord,
                pageNum, pageSize);*/
        UsersLikeVideosVo usersLikeVideosVo = userLikeVideoService.like(userId, videoId);
        return IMoocJSONResult.ok(usersLikeVideosVo);
    }


    @PostMapping("/likeslist")
    @ApiOperation(value = "获取用户点赞的视频列表", notes = "获取用户点赞的视频列表")
    @ApiImplicitParam(name = "userId", value = "用户id", required = true, dataType = "String", paramType = "query")
    public IMoocJSONResult likeslist(String userId) {

        return IMoocJSONResult.ok();
    }

    /**
     * 是否点赞某个视频
     *
     * @param userId
     * @return
     */
    @PostMapping("/isLikeVideo")
    @ApiOperation(value = "是否点赞视频", notes = "是否点赞视频的接口 ")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "用户id", required = true, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "videoId", value = "视频id", required = true, dataType = "String", paramType = "query")

    })
    public IMoocJSONResult isLikeVideo(String userId, String videoId) {
        return IMoocJSONResult.ok(userLikeVideoService.isLikeVideo(userId, videoId));
    }

}
